def containsDuplicate(nums):
    s = set()
    for num in nums:
        if num in s:
            return True
        else:
            s.add(num)
    return False


nums = [1, 2, 3, 1]
print(containsDuplicate(nums))  # True
